new Vue({
    el:'#lazyVue',
    data:{
        items:[],
        busy:false,
        finish:false,
        url:null,
        need_token:null,
        data:{}
    },
    methods:{
        loadMore(){
            var newItems = [];
            for (let i=0; i<10; i++) {
                newItems.push({title:'Hello World!'})
            }
            this.items = [...this.items, ...newItems];
        }
    },
    directives:{
        lazyLoad:{
            bind: function (el, binding) {
                this.url = el.getAttribute("url");
                this.need_token = el.getAttribute("need_token");

                var doScroll = function () {
                    if(document.body.scrollTop + window.innerHeight >= el.clientHeight){
                        var fnc = binding.value;
                        fnc();
                    }
                };
                window.addEventListener('scroll',doScroll);
            },
        }
    }
});
